<template>
    <div class="main">
        <span>账号余额 {{ account }} 元</span><span>积分 {{ integral }} 分</span>
    </div>
</template>

<script lang="ts" setup>
import {ref,watchEffect} from 'vue'
import { getUserInfoList } from '@/api'; 


const account = ref<number>()
const integral = ref<number>()

watchEffect(async()=>{
    // console.log('watchEffect');
    try{
        //等待异步代码完成
        const {data} : any = await getUserInfoList()
    
        
        // console.log('data',data[0].params);
        // console.log('id',data);
        
        //处理得到的数据
        if(data){
            account.value = data[0].account
            integral.value = data[0].integral
        }
    } catch(error) {
        console.error('发生错误',error);  
    } 
})




</script>

<style lang="scss" scoped>
.main{
    background-color: #fff;
    margin: 20px;
    padding: 20px;
    overflow: hidden;
    display: flex;
}
span{
    width: 50%;
}

</style>
